package com.openbravo.pos.ticket;

import com.openbravo.basic.BasicException;
import com.openbravo.data.gui.ComboBoxValModel;
import com.openbravo.data.gui.ListQBFModelNumber;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.QBFCompareEnum;
import com.openbravo.data.loader.SentenceList;
import com.openbravo.data.loader.SerializerWrite;
import com.openbravo.data.loader.SerializerWriteBasic;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.AppView;
import com.openbravo.pos.forms.DataLogicSales;
import com.openbravo.pos.reports.ReportEditorCreator;

import java.awt.Component;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;

public class ProductFilter extends JPanel
  implements ReportEditorCreator
{
  private SentenceList m_sentcat;
  private ComboBoxValModel m_CategoryModel;
  private JLabel jLabel1;
  private JLabel jLabel2;
  private JLabel jLabel3;
  private JLabel jLabel4;
  private JLabel jLabel5;
  private JPanel jPanel1;
  private JPanel jPanel2;
  private JTextField m_jBarcode;
  private JComboBox m_jCategory;
  private JComboBox m_jCboName;
  private JComboBox m_jCboPriceBuy;
  private JComboBox m_jCboPriceSell;
  private JTextField m_jName;
  private JTextField m_jPriceBuy;
  private JTextField m_jPriceSell;

  public ProductFilter()
  {
    initComponents();
  }

  public void init(AppView paramAppView)
  {
    DataLogicSales localDataLogicSales = (DataLogicSales)paramAppView.getBean("com.openbravo.pos.forms.DataLogicSales");
    this.m_sentcat = localDataLogicSales.getCategoriesList();
    this.m_CategoryModel = new ComboBoxValModel();
    this.m_jCboName.setModel(ListQBFModelNumber.getMandatoryString());
    this.m_jCboPriceBuy.setModel(ListQBFModelNumber.getMandatoryNumber());
    this.m_jCboPriceSell.setModel(ListQBFModelNumber.getMandatoryNumber());
  }

  public void activate()
    throws BasicException
  {
    List localList = this.m_sentcat.list();
    localList.add(0, null);
    this.m_CategoryModel = new ComboBoxValModel(localList);
    this.m_jCategory.setModel(this.m_CategoryModel);
  }

  public SerializerWrite getSerializerWrite()
  {
    return new SerializerWriteBasic(new Datas[] { Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.DOUBLE, Datas.OBJECT, Datas.DOUBLE, Datas.OBJECT, Datas.STRING, Datas.OBJECT, Datas.STRING });
  }

  public Component getComponent()
  {
    return this;
  }

  public Object createValue()
    throws BasicException
  {
    if ((this.m_jBarcode.getText() == null) || (this.m_jBarcode.getText().equals("")))
      return new Object[] { this.m_jCboName.getSelectedItem(), this.m_jName.getText(), this.m_jCboPriceBuy.getSelectedItem(), Formats.CURRENCY.parseValue(this.m_jPriceBuy.getText()), this.m_jCboPriceSell.getSelectedItem(), Formats.CURRENCY.parseValue(this.m_jPriceSell.getText()), this.m_CategoryModel.getSelectedKey() == null ? QBFCompareEnum.COMP_NONE : QBFCompareEnum.COMP_EQUALS, this.m_CategoryModel.getSelectedKey(), QBFCompareEnum.COMP_NONE, null };
    return new Object[] { QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_NONE, null, QBFCompareEnum.COMP_RE, "%" + this.m_jBarcode.getText() + "%" };
  }

  private void initComponents()
  {
    this.jPanel2 = new JPanel();
    this.jLabel5 = new JLabel();
    this.m_jBarcode = new JTextField();
    this.jPanel1 = new JPanel();
    this.jLabel1 = new JLabel();
    this.jLabel3 = new JLabel();
    this.jLabel4 = new JLabel();
    this.m_jCboName = new JComboBox();
    this.m_jName = new JTextField();
    this.m_jPriceBuy = new JTextField();
    this.m_jCboPriceBuy = new JComboBox();
    this.m_jCboPriceSell = new JComboBox();
    this.m_jPriceSell = new JTextField();
    this.m_jCategory = new JComboBox();
    this.jLabel2 = new JLabel();
    this.jPanel2.setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.bybarcode")));
    this.jLabel5.setText(AppLocal.getIntString("label.prodbarcode"));
    GroupLayout localGroupLayout1 = new GroupLayout(this.jPanel2);
    this.jPanel2.setLayout(localGroupLayout1);
    localGroupLayout1.setHorizontalGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout1.createSequentialGroup().addContainerGap().addComponent(this.jLabel5, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jBarcode, -2, 150, -2).addGap(348, 348, 348)));
    localGroupLayout1.setVerticalGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout1.createSequentialGroup().addGap(1, 1, 1).addGroup(localGroupLayout1.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel5).addComponent(this.m_jBarcode, -2, -1, -2)).addContainerGap(-1, 32767)));
    this.jPanel1.setBorder(BorderFactory.createTitledBorder(AppLocal.getIntString("label.byform")));
    this.jLabel1.setText(AppLocal.getIntString("label.prodcategory"));
    this.jLabel3.setText(AppLocal.getIntString("label.prodpricesell"));
    this.jLabel4.setText(AppLocal.getIntString("label.prodpricebuy"));
    this.jLabel2.setText(AppLocal.getIntString("label.prodname"));
    GroupLayout localGroupLayout2 = new GroupLayout(this.jPanel1);
    this.jPanel1.setLayout(localGroupLayout2);
    localGroupLayout2.setHorizontalGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addContainerGap().addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addComponent(this.jLabel2, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCboName, -2, 150, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jName, -2, 180, -2)).addGroup(localGroupLayout2.createSequentialGroup().addComponent(this.jLabel4, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCboPriceBuy, -2, 150, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jPriceBuy, -2, 60, -2)).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.TRAILING, false).addGroup(GroupLayout.Alignment.LEADING, localGroupLayout2.createSequentialGroup().addComponent(this.jLabel1, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, -1, 32767).addComponent(this.m_jCategory, -2, 220, -2)).addGroup(GroupLayout.Alignment.LEADING, localGroupLayout2.createSequentialGroup().addComponent(this.jLabel3, -2, 130, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jCboPriceSell, -2, 150, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jPriceSell, -2, 60, -2)))).addContainerGap(-1, 32767)));
    localGroupLayout2.setVerticalGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout2.createSequentialGroup().addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.m_jCboName, -2, 20, -2).addComponent(this.m_jName, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel4).addComponent(this.m_jCboPriceBuy, -2, 20, -2).addComponent(this.m_jPriceBuy, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel3).addComponent(this.m_jCboPriceSell, -2, 20, -2).addComponent(this.m_jPriceSell, -2, -1, -2)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(localGroupLayout2.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel1).addComponent(this.m_jCategory, -2, 20, -2)).addContainerGap(-1, 32767)));
    GroupLayout localGroupLayout3 = new GroupLayout(this);
    setLayout(localGroupLayout3);
    localGroupLayout3.setHorizontalGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(this.jPanel2, -1, 512, 32767).addComponent(this.jPanel1, -1, -1, 32767));
    localGroupLayout3.setVerticalGroup(localGroupLayout3.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(localGroupLayout3.createSequentialGroup().addComponent(this.jPanel2, -2, -1, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jPanel1, -2, -1, -2)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.ticket.ProductFilter
 * JD-Core Version:    0.6.0
 */